#include <cstdio>
#include <cstring>

char a[ 10001 ], b[ 1000001 ];
int next[ 10001 ];

void getnext( char *a )
{
    int i = 1, j = -1;
    next[ 0 ] = -1;
    while ( a[ i ] )
    {
        while ( j >= 0 && a[ j + 1 ] != a[ i ] ) j = next[ j ];
        if ( a[ j + 1 ] == a[ i ] ) j++;
        next[ i++ ] = j;
    }
}

int match( char *a, char *b )
{
    int i = 0, j = -1, ret = 0;
    while ( a[ i ] )
    {
        while ( j >= 0 && b[ j + 1 ] != a[ i ] ) j = next[ j ];
        if ( b[ j + 1 ] == a[ i ] ) j++;
        if ( !b[ j + 1 ] )
        {
            ret++;
            j = next[ j ];
        }
        i++;
    }
    return ret;
}

int main( )
{
    int t;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%s%s", a, b);
        getnext( a );
        printf("%d\n", match( b, a ));
    }
}
